if (!PRIVATE_KEY) throw"⛔️ Private key not detected! Add it to the .env file!";
// An example of a deploy script that will deploy and call a simple contract. exportdefaultasyncfunction (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the Greeter contract`);
// Initialize the wallet. const wallet = newWallet(PRIVATE_KEY);
// Create deployer object and load the artifact of the contract you want to deploy. const deployer = newDeployer(hre, wallet); const artifact = await deployer.loadArtifact("Greeter");
// ⚠️ OPTIONAL: You can skip this block if your account already has funds in L2 // Deposit funds to L2 // const depositHandle = await deployer.zkWallet.deposit({ // to: deployer.zkWallet.address, // token: utils.ETH_ADDRESS, // amount: deploymentFee.mul(2), // }); // // Wait until the deposit is processed on zkSync // await depositHandle.wait();
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. // `greeting` is an argument for contract constructor. const parsedFee = ethers.utils.formatEther(deploymentFee.toString()); console.log(`The deployment is estimated to cost ${parsedFee} ETH`);
//obtain the Constructor Arguments console.log("Constructor args:" + greeterContract.interface.encodeDeploy([greeting]));
// Show the contract info. const contractAddress = greeterContract.address; console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
// verify contract for testnet & mainnet if (process.env.NODE_ENV != "test") { // Contract MUST be fully qualified name (e.g. path/sourceName:contractName) const contractFullyQualifedName = "contracts/Greeter.sol:Greeter";
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !